package com.aaa.controller.mht;

import com.aaa.entity.LayData;
import com.aaa.entity.MyPage;
import com.aaa.entity.TmhtPlane;
import com.aaa.entity.User;
import com.aaa.service.mht.TmhtPlaneService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.Date;

/**
 * (TmhtPlane)表控制层
 *
 * @author yuyongli
 * @since 2022-10-25 15:46:55
 */
@RestController
@RequestMapping("tMhtPlane")
public class TmhtPlaneController {
    /**
     * 服务对象
     */
    @Autowired
    private TmhtPlaneService tmhtPlaneService;


    // 查询所有的执行计划
    @GetMapping
    public LayData queryAll(MyPage myPage){
       return new LayData(tmhtPlaneService.queryAll(myPage));
    }

    @PostMapping
    public LayData checkCode(TmhtPlane plane){
        return new LayData(tmhtPlaneService.selectPlane(plane));
    }
    @PostMapping("addPlane")
    public LayData addPlane(TmhtPlane plane, HttpSession session){
        User user1=(User) session.getAttribute("user");
        plane.setCreatetime(new Date());
        plane.setUid(user1.getId());
        System.out.println(plane);
        return new LayData(tmhtPlaneService.insertPlane(plane));
    }

    @GetMapping("getByCode")
    public LayData queryByQyCode(TmhtPlane tmhtPlane){
        return new LayData(tmhtPlaneService.queryByQyCode(tmhtPlane));
    }

}

